package com.asa.hutils.teizheng;


import com.asa.hutils.teizheng.structure.Matrix;

public class HessenbergHouseholderReflection extends AbstractHouseholderReflection {
	
	protected double[] getXAtSpecifiedColumn(Matrix R, int column) {
		double[] x = new double[R.rows()];
		for(int m=0; m<x.length; m++) {
			if(m <= column) {
				x[m] = 0;
			} else {
				x[m] = R.at(m, column);
			}
		}
		return x;
	}
	
	protected double[] getWAtSpecifiedColumn(int column, double[] x) {
		double[] w = new double[x.length];
		double lengthOfVector = 0;
		for(int j=0; j<x.length; j++) {
			lengthOfVector += Math.pow(x[j], 2);
		}
		lengthOfVector = Math.sqrt(lengthOfVector);
		w[column + 1] = lengthOfVector;
		for(int m=0; m<w.length; m++) {
			if(m != column + 1 ) {
				w[m] = 0;
			}				
		}
		return w;
	}

}
